import Vue from 'vue'
import VueRouter from 'vue-router'
//homepage
import Home from '@/views/Documents/Changelog'
//mudules
import Dashboard from './modules/Dashboard'
import LiveRecord from './modules/LiveRecord'
import BatchRecord from './modules/BatchRecord'
import Summary from './modules/Summary'
import Query from './modules/Query'
import Management from './modules/Management'
import Documents from './modules/Documents'
import Notice from './modules/Notice'
//utils
import Handler from './utils/Handler'

Vue.use(VueRouter)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/About',
    name: 'About',
    component: () => import('@/views/About')
  },
  LiveRecord,
  BatchRecord,
  Summary,
  Query,
  Management,
  Documents,
  Dashboard,
  Notice,
]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => Handler.before(from, to, next, router.app.$store))


export default router